#ifndef _SUBJECT_H_
#define _SUBJECT_H_

#include "observer.h"
#include <string>
#include <list>

using std::string;
using std::list;

class Observer;

//管理观察者
class Subject
{
public:
	virtual ~Subject();

	virtual void Notify();
	virtual void Attach(Observer*);
	virtual void Detach(Observer*);
	virtual void SetState(string state);
	virtual string GetState();
	virtual void DoSomething() = 0;
protected:
	Subject();

private:
	list<Observer*> ob_list_;
	string state_;
};

class ConcreteSubjectA : public Subject
{
public:
	ConcreteSubjectA();
	~ConcreteSubjectA();

	// 具体业务
	virtual void DoSomething();
};

class ConcreteSubjectB : public Subject
{
public:
	ConcreteSubjectB();
	~ConcreteSubjectB();

	// 具体业务
	virtual void DoSomething();
};

#endif // _SUBJECT_H_